<?php
namespace App\Http\Service;


use App\Models\HonestassetMediareport;

class HonestassetMediareportService{

    public static function getMediareportListPageInit($pageSize=DEFAULT_PAGESIZE,$where=[],$searchVal=null){
        $entity=HonestassetMediareport::where($where)
            ->orderby('sort','DESC')
            ->orderby('id','DESC');
        if(!empty($searchVal)){
            return $entity->where('name','like','%'.$searchVal.'%')
                ->paginate($pageSize);
        }
        return $entity->paginate($pageSize);
    }

    public static function  getTypeList(){
        return HonestassetMediareport::getTypeList();
    }

    public static function createOneMediareport($mediaData){
        return HonestassetMediareport::create($mediaData);
    }

    public static function getOneMediareport($mediaId){
        return HonestassetMediareport::find($mediaId);
    }

    public static function deleteOneMediareport($mediaId){
        return HonestassetMediareport::find($mediaId)
                    ->update(['isdelete'=>1]);
    }

    public static function updateOneMediareport($mediaData){
        return HonestassetMediareport::find($mediaData['id'])
            ->update($mediaData);
    }

    public static function getOneReportWhere($where){
        return HonestassetMediareport::where($where)
            ->orderby('sort','DESC')
            ->orderby('id','DESC')
            ->get();

    }
}